$(document).ready(function(){
	
	$("#seadedNupp").click(function(){
		toggleOverlay();
		alert("siin avanevad seaded");
		$("html").css("background-image","url('images/waves.jpg')");
		toggleOverlay();
	});
	
	$("#abiNupp").click(function(){
		toggleOverlay();
		alert("siin avaneb mingi abi");
		$("html").css("background-image","url('images/laevad.jpg')");
		toggleOverlay();
	});
	
	$("#chatInput").keypress(function(event){
		if(event.which==13){
			$("#scroll").html(this.value + "<br />" + $("#scroll").html());
			this.value="";
		}
	});
	$("#mainbutton").click(function(){
		toggleOverlay();
		alert("Let the destruction begin!");
		toggleOverlay();
	});
	$("#enemyField .field .kuubik").click(function(){
		$(this).css("opacity","1");
		$(this).css("background-color","transparent");
	});
});

function toggleOverlay(){
	var elem = $("#overlay");
	if(elem.css("display") == "none"){
		elem.css("display","block");
	} else {
		elem.css("display","none");
	}
}